Parser

A stateful object that this is used to produce a Tree based on some source code

Constructors

this
this(Language language)

Create a new Parser for the given language. NOTE: It assumes that the language is compatible (uses set_language_nothrow).

this
this()
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Functions

enforce_compatible_language
void enforce_compatible_language(Language language)

Throws an error if the version of the given language is not compatible

language
auto language()

Get the parser's current language.

logger
TSLogger* logger()

Get the parser's current logger.

parse
auto parse(TSInput input, TSTree* old_tree)

Use the parser to parse some source code and create a syntax tree.

parse
auto parse(string source_code, TSTree* old_tree)

Use the parser to parse some source code stored in one contiguous buffer. The first two parameters are the same as in the ts_parser_parse function above. The second two parameters indicate the location of the buffer and its length in bytes.

parse
auto parse(string source_code, TSInputEncoding encoding, TSTree* old_tree)

Use the parser to parse some source code stored in one contiguous buffer with a given encoding. The first four parameters work the same as in the ts_parser_parse_string method above. The final parameter indicates whether the text is encoded as UTF8 or UTF16.

parse_utf16
auto parse_utf16(wstring source_code, TSTree* old_tree)

Parse the given source_code that is in utf16 encoding

parse_utf8
auto parse_utf8(string source_code, TSTree* old_tree)

Parse the given source_code that is in utf8 encoding

print_dot_graphs
auto print_dot_graphs(File file)

Set the destination to which the parser should write debugging graphs during parsing. The graphs are formatted in the DOT language. You may want to pipe these graphs directly to a dot(1) process in order to generate SVG output.

s_expression
auto s_expression(string source_code)

Get the S-expression of the given source code

set_language
auto set_language(Language language)

Set the language that the parser should use for parsing.

set_language_nothrow
auto set_language_nothrow(Language language)

Set the language that the parser should use for parsing.

stop_printing_dot_graphs
auto stop_printing_dot_graphs()

Stop the parser from printing debugging graphs while parsing.

traverse
void traverse(string source_code, TreeVisitor visitor)

Traverse the Tree starting from its root Node applying a visitor at all nodes.

traverse_print
string traverse_print(string source_code)

Traverse the Tree starting from its root Node and print information about each

Variables

tsparser
TSParser* tsparser;

internal TSParser

Meta